'use strict'

const {DataTypes, Model, Op } = require('../../azeroth').sequelize;
class FlawIFilternfo extends Model {}

const initFlawFilterData = (sequelize_aim) => {
  FlawIFilternfo.init(
    {
      id: {
          field: 'id',
          type: DataTypes.BIGINT(11) ,
          allowNull: false,
          primaryKey: true,
          autoIncrement: true,
      },
      panel_id: {
          field: 'panel_id',
          type: DataTypes.STRING,
      },
      panel_table_uid: {
          field: 'panel_table_uid',
          type: DataTypes.INTEGER,
      },
      flaw_class_type: {
          field: 'flaw_class_type',
          type: DataTypes.INTEGER,
      },
      station_id: {
          field: 'station_id',
          type: DataTypes.INTEGER,
      },
      station_name: {
          field: 'station_name',
          type: DataTypes.STRING,
      },
      show: {
          field: 'show',
          type: DataTypes.STRING,
      },
      flaw_count: {
          field: 'flaw_count',
          type: DataTypes.INTEGER,
      },
      symbol: {
          field: 'symbol',
          type: DataTypes.STRING,
      },
      color: {
          field: 'color',
          type: DataTypes.STRING,
      },
      shape: {
          field: 'shape',
          type: DataTypes.INTEGER,
      },
    },
    {
      freezeTableName: true,
      sequelize: sequelize_aim,
      modelName: 'flaw_filter',
      timestamps: false
    }
  )
}

FlawIFilternfo.uploadFlawIFilternfo = async (data) => {
  let res = await FlawIFilternfo.bulkCreate([...data], {
    updateOnDuplicate: ['id', 'station_id', 'flaw_class_type', 'show', 'flaw_count', 'symbol', 'color', 'station_name', 'shape', 'panel_id', 'panel_table_uid']
  });
  return res;
}

module.exports = {
  FlawIFilternfo,
  initFlawFilterData
};